package com.situ.service.impl;

import com.situ.dao.impl.StudentDaoImpl;
import com.situ.pojo.Student;
import com.situ.pojo.search.StudentDTO;
import com.situ.service.StudentService;
import com.situ.util.BeanFactory;
import com.situ.util.Pagination;

import java.util.List;

public class StudentServiceImpl implements StudentService {
    StudentDaoImpl studentDao = BeanFactory.getBean(StudentDaoImpl.class);

    @Override
    public List<Student> findAll(Pagination pagination, StudentDTO studentDTO) {
        return studentDao.findAll(pagination, studentDTO);
    }

    @Override
    public int deleteByIds(List<Integer> ids) {
        if (ids != null && !ids.isEmpty()) {
            return studentDao.deleteByIds(ids);
        }else {
            return -1;
        }
    }

    @Override
    public boolean add(Student student) {
        int add = studentDao.add(student);
            return add > 0;
    }

    @Override
    public Student findById(Integer id) {
        return studentDao.findById(id);
    }

    @Override
    public boolean edit(Student student) {
        int add = studentDao.edit(student);
        return add > 0;
    }
}
